<?php


namespace common\utils;


class StrUntil
{
    public static function ch2arr($str)
    {
        $length = mb_strlen($str, 'utf-8');
        $array = [];
        for ($i = 0; $i < $length; $i++)
            $array[] = mb_substr($str, $i, 1, 'utf-8');
        return $array;
    }

    public static function getBaseNameByUrl($url)
    {
        $arr = parse_url($url);
        $arr2 = pathinfo($arr['path']);
        return $arr2['basename'];
    }

    public static function getExtensionByUrl($url)
    {
        $arr = parse_url($url);
        $arr2 = pathinfo($arr['path']);
        return isset($arr2['extension']) ? $arr2['extension'] : '';
    }
}